<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);
return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
        ],
        'response' => [
            'format' => 'json',
            'class' => 'yii\web\Response',
            'on beforeSend' => function ($event) {
                $response = $event->sender;
                $response->data = [
                    'success' => $response->isSuccessful,
                    'code' => $response->getStatusCode(),
                    'message' => $response->statusText,
                    'data' => $response->data,
                ];
                $response->statusCode = 200;
            },
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],

        'cache' => [
//            'class' => 'yii\caching\FileCache',
            'class'=>'yii\redis\Cache',//使用redis缓存作为项目缓存
            'redis'=>[
                'hostname' => '127.0.0.1',
                'port' =>'6379' ,
                'database' => 0
            ],
        ],

        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'backend',
            'timeout'=>7200,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'urlManager' => [
            'class'=>'common\components\UrlManager',
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'pluralize'     => false,  // 关闭复数形式
                    'controller' => [
                        'user',
                    ],

                ],
                'user/say/<id:\d+>' => 'user/say',
                'login' => 'login/login',
                'get_code' => 'login/get-pic-code',
                'logout' => 'login/logout',
                'login_log_list' => 'tools/login-log-list',
                'log_action_list' => 'tools/log-action-list',
                'login/<username:\d+>/<password>' => 'login/login',
                'admin_index' => 'member/admin-index',
                'member_list' => 'member/list',
                'group_member_detail' => 'member/group-member-detail',
                'set_posts_auth' => 'member/set-posts-auth',
                'group_cat_list' => 'group/group-cat-list',
                'add_group_cat' => 'group/add-group-cat',
                'group_cat_detail' => 'group/group-cat-detail',
                'save_group_cat' => 'group/save-group-cat',
                'delete_group_cat' => 'group/delete-group-cat',
                'group_list' => 'group/group-list',
                'add_group' => 'group/add-group',
                'group_detail' => 'group/group-detail',
                'save_group' => 'group/save-group',
                'delete_group' => 'group/delete-group',
                'movie_list' => 'movie/movie-list',
                'add_movie' => 'movie/add-movie',
                'movie_detail' => 'movie/movie-detail',
                'save_movie' => 'movie/save-movie',
                'delete_movie' => 'movie/delete-movie',
                'posts_list' => 'posts/posts-list',
                'add_posts' => 'posts/add-posts',
                'check_posts' => 'posts/check-posts',
                'posts_detail' => 'posts/posts-detail',
                'delete_posts' => 'posts/delete-posts',
                'comment_list' => 'posts/comment-list',
                'add_comment' => 'posts/add-comment',
                'comment_detail' => 'posts/comment-detail',
                'check_comment' => 'posts/check-comment',
                'delete_comment' => 'posts/delete-comment',
                'task_list' => 'active/task-list',
                'task_detail' => 'active/task-detail',
                'save_task' => 'active/save-task',
                'weal_list' => 'active/weal-list',
                'add_weal' => 'active/add-weal',
                'weal_detail' => 'active/weal-detail',
                'save_weal' => 'active/save-weal',
                'delete_weal' => 'active/delete-weal',
                'weal_exchange_list' => 'active/weal-exchange-list',
                'set_weal' => 'active/set-weal',
                'user_add' => 'admin/user-add',

                //权限管理会员相关
                'get_auth_role'=>'admin/get-auth-role',
                'get_user_list'=>'admin/get-user-list',
//                'get_user_list/true_name/<true_name:\w*>/mobile/<mobile:\d+>/excel_download/<excel_download:\d+>' => 'admin/get-user-list',
                'get_user_info'=>'admin/get-user-info',
                'get_target_user_info'=>'admin/get-target-user-info',
                'modify_password'=>'admin/modify-password',
                'user_info_edit'=>'admin/user-info-edit',
                'user_avatar_upload'=>'admin/avatar-upload',
                'add_user_access'=>'admin/add-user-access',
                'admin_delete_user'=>'admin/delete-user',
                'modify_self_password'=>'admin/modify-self-password',  //登录用户修改自身密码
                'user_self_info_edit'=>'admin/user-self-info-edit', //登录用户修改自身信息

                //权限管理角色相关
                'get_auth_role_list'=>'auth-group/get-auth-role-list',
                'get_auth_role_info'=>'auth-group/get-auth-role-info',
                'delete_auth_role'=>'auth-group/delete-auth-role',
                'get_auth_tree_list'=>'auth-group/get-auth-tree-list',
                'edit_role_info'=>'auth-group/edit-role-info',
                'add_role_info'=>'auth-group/add-role-info',
                'give_role_auth'=>'auth-group/give-role-auth',

                //权限管理节点相关
                'get_auth_rule_list'=>'auth-rule/get-auth-rule-list',
//                'get_auth_rule_list/excel_download/<excel_download:\d+>' => 'auth-rule/get-auth-role-list',
                'del_auth_rule'=>'auth-rule/delete-rule',
                'edit_auth_rule'=>'auth-rule/edit-rule',
                'add_auth_rule'=>'auth-rule/add-rule',
                'get_auth_rule_info'=>'auth-rule/get-auth-rule-info',

                //banner相关
                'get_banner_list'=>'banner/get-banner-list',
                'get_banner_class_list'=>'banner/get-banner-class-list',
//                'get_banner_list/title/<title:\w*>/status/<status:\w*>/excel_download/<excel_download:\d+>' => 'banner/get-banner-list',
                'update_banner_state'=>'banner/update-banner-state',
                'del_banner_state'=>'banner/del-banner-state',
                'update_banner_info'=>'banner/update-banner-info',
                'add_banner_info'=>'banner/add-banner-info',

                //资讯相关
                'get_information_list'=>'information/get-information-list',
//                'get_information_list/title/<title:\w*>/excel_download/<excel_download:\d+>' => 'information/get-information-list',
                'del_information'=>'information/del-information',
                'edit_information'=>'information/edit-information',
                'add_information'=>'information/add-information',
                'get_information_info'=>'information/get-information-info',

                //资讯分类相关
                'get_information_class_list'=>'information-class/get-information-class-list',
//                'get_information_class_list/title/<title:\w*>/excel_download/<excel_download:\d+>' => 'information-class/get-information-class-list',
                'del_information_class'=>'information-class/del-information-class',
                'update_information_class'=>'information-class/update-information-class',
                'edit_information_class'=>'information-class/edit-information-class',
                'add_information_class'=>'information-class/add-information-class',

                //项目相关
                'get_project_class_list'=>'project/get-project-class-list',
//                'get_project_class_list/title/<title:\w*>/status/<status:\w*>/excel_download/<excel_download:\d+>' => 'project/get-project-class-list',
                'update_project_class_state'=>'project/update-project-class-state',
                'del_project_class_state'=>'project/del-project-class-state',
                'update_project_class_info'=>'project/update-project-class-info',
                'add_project_class_info'=>'project/add-project-class-info',

                'get_project_type_list'=>'project/get-project-type-list',
//                'get_project_type_list/title/<title:\w*>/status/<status:\w*>/excel_download/<excel_download:\d+>' => 'project/get-project-type-list',
                'update_project_type_state'=>'project/update-project-type-state',
                'del_project_type_state'=>'project/del-project-type-state',
                'update_project_type_info'=>'project/update-project-type-info',
                'add_project_type_info'=>'project/add-project-type-info',

                'get_project_list'=>'project/get-project-list',
//                'get_project_list/title/<title:\w*>/class_id/<class_id:\w*>/excel_download/<excel_download:\d+>' => 'project/get-project-list',
                'update_project_state'=>'project/update-project-state',
                'del_project_state'=>'project/del-project-state',
                'get_project_info'=>'project/get-project-info',
                'update_project_info'=>'project/update-project-info',
                'update_project_other_info'=>'project/update-project-other-info',
                'add_project_info'=>'project/add-project-info',

                'get_project_actor_list'=>'project/get-project-actor-list',
                'get_project_actor_info'=>'project/get-project-actor-info',
                'del_project_actor'=>'project/del-project-actor',
                'update_project_actor_info'=>'project/update-project-actor-info',
                'add_project_actor_info'=>'project/add-project-actor-info',

                'get_project_video_list'=>'project/get-project-video-list',
                'update_project_video_info'=>'project/update-project-video-info',
                'add_project_video_info'=>'project/add-project-video-info',

                'get_project_picture_list'=>'project/get-project-picture-list',
                'update_project_picture_info'=>'project/update-project-picture-info',
                'add_project_picture_info'=>'project/add-project-picture-info',
            ],
        ]
    ],
    'params' => $params,
];
